define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_VectorTileLayer', function (sourceId, url,clientId, clientSecret ) {
        try {
            var layer = new egis.carto.MVTVectorTileLayer({
                "glStyle": url,
                "clientId": clientId,
                "clientSecret": clientSecret,
            })
            //map.addLayer(layer);
            //layer.loadStyle(styles['standard'].styleUrl)
            Window.container[sourceId] = layer;
        }
        catch (e) {
            alert(e)
        }
    })

    dsBridge.register('VectorTileLayer_loadStyle', function (sourceId, style, diff) {
        var layer = Window.container[sourceId];
        if (!style) {
            style = 'file:///android_asset/resource/data/style.json';
        }
        if(!diff){
            style = JSON.parse(style);
        }
        layer.loadStyle(style, {diff: diff});
        /*setTimeout(function () {
            try {
                layer._glMap.panBy([20, 20]);
                layer._glMap.panBy([-20, -20]);
                alert(0)
            }
            catch (e) {
                alert(e);
            }
        }, 2000);*/
    })
    var styles = {
        "standard": {
            spritesUrl: "http://yjqz.geo-compass.com/api/v1/sprites/1/sprite@2x.json", // http://10.18.1.185:80/api/v1/sprites/1/sprite.json
            spritesImgUrl: "http://yjqz.geo-compass.com/api/v1/sprites/1/sprite@2x.png", //http://10.18.1.185:80/api/v1/sprites/1/sprite.png
            styleUrl: "http://yjqz.geo-compass.com/api/v1/styles/1"   // http://10.18.1.185/api/v1/styles/1
        },
        "blueGlobe2": {
            spritesUrl: "http://yjqz.geo-compass.com/api/v1/sprites/2/sprite@2x.json",
            spritesImgUrl: "http://yjqz.geo-compass.com/api/v1/sprites/2/sprite@2x.png",
            styleUrl: "http://yjqz.geo-compass.com/api/v1/styles/2"
        },
        "blueChina": {
            spritesUrl: "http://yjqz.geo-compass.com/api/v1/sprites/3/sprite@2x.json",
            spritesImgUrl: "http://yjqz.geo-compass.com/api/v1/sprites/3/sprite@2x.png",
            styleUrl: "http://yjqz.geo-compass.com/api/v1/styles/3"
        },
        "whiteGlobe2": {
            spritesUrl: "http://yjqz.geo-compass.com/api/v1/sprites/4/sprite@2x.json",
            spritesImgUrl: "http://yjqz.geo-compass.com/api/v1/sprites/4/sprite@2x.png",
            styleUrl: "http://yjqz.geo-compass.com/api/v1/styles/4"
        },
        "whiteChina": {
            spritesUrl: "http://yjqz.geo-compass.com/api/v1/sprites/5/sprite@2x.json",
            spritesImgUrl: "http://yjqz.geo-compass.com/api/v1/sprites/5/sprite@2x.png",
            styleUrl: "http://yjqz.geo-compass.com/api/v1/styles/5"
        },
        "blueGlobe1": {
            spritesUrl: "http://yjqz.geo-compass.com/api/v1/sprites/6/sprite@2x.json",
            spritesImgUrl: "http://yjqz.geo-compass.com/api/v1/sprites/6/sprite@2x.png",
            styleUrl: "http://yjqz.geo-compass.com/api/v1/styles/6"
        },
        "whiteGlobe1": {
            spritesUrl: "http://yjqz.geo-compass.com/api/v1/sprites/7/sprite@2x.json",
            spritesImgUrl: "http://yjqz.geo-compass.com/api/v1/sprites/7/sprite@2x.png",
            styleUrl: "http://yjqz.geo-compass.com/api/v1/styles/7"
        }
    }
})